package com.only4play.authcenter.domain.customeraccount;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-03-05
 */
import com.only4play.authcenter.infrastructure.constanst.MyConstants;
import com.only4play.codegen.processor.api.GenCreateRequest;
import com.only4play.codegen.processor.api.GenFeign;
import com.only4play.codegen.processor.api.GenQueryRequest;
import com.only4play.codegen.processor.api.GenResponse;
import com.only4play.codegen.processor.api.GenUpdateRequest;
import com.only4play.codegen.processor.controller.GenController;
import com.only4play.codegen.processor.creator.GenCreator;
import com.only4play.codegen.processor.mapper.GenMapper;
import com.only4play.codegen.processor.query.GenQuery;
import com.only4play.codegen.processor.repository.GenRepository;
import com.only4play.codegen.processor.service.GenService;
import com.only4play.codegen.processor.creator.IgnoreCreator;
import com.only4play.codegen.processor.updater.IgnoreUpdater;
import com.only4play.codegen.processor.service.GenServiceImpl;
import com.only4play.codegen.processor.updater.GenUpdater;
import com.only4play.codegen.processor.vo.GenVo;
import com.only4play.common.annotation.FieldDesc;
import com.only4play.common.annotation.TypeConverter;
import com.only4play.common.constants.ValidStatus;
import com.only4play.jpa.converter.ValidStatusConverter;
import com.only4play.jpa.support.BaseJpaAggregate;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import lombok.Data;

@GenVo(pkgName = "com.only4play.authcenter.domain.customeraccount.vo")
@GenCreator(pkgName = "com.only4play.authcenter.domain.customeraccount.creator")
@GenUpdater(pkgName = "com.only4play.authcenter.domain.customeraccount.updater")
@GenRepository(pkgName = "com.only4play.authcenter.domain.customeraccount.repository")
@GenService(pkgName = "com.only4play.authcenter.domain.customeraccount.service")
@GenServiceImpl(pkgName = "com.only4play.authcenter.domain.customeraccount.service")
@GenQuery(pkgName = "com.only4play.authcenter.domain.customeraccount.query")
@GenMapper(pkgName = "com.only4play.authcenter.domain.customeraccount.mapper")
@GenController(pkgName = "com.only4play.authcenter.controller")
@GenCreateRequest(pkgName = "com.only4play.authcenter.api.customeraccount.request",sourcePath = MyConstants.GEN_API_SOURCE)
@GenUpdateRequest(pkgName = "com.only4play.authcenter.api.customeraccount.request",sourcePath = MyConstants.GEN_API_SOURCE)
@GenQueryRequest(pkgName = "com.only4play.authcenter.api.customeraccount.request",sourcePath = MyConstants.GEN_API_SOURCE)
@GenResponse(pkgName = "com.only4play.authcenter.api.customeraccount.response",sourcePath = MyConstants.GEN_API_SOURCE)
@GenFeign(pkgName = "com.only4play.authcenter.api.customeraccount.service",sourcePath = MyConstants.GEN_API_SOURCE,serverName ="auth-srv")
@Entity
@Table(name = "third_party_auth")
@Data
public class ThirdPartyAuth extends BaseJpaAggregate {

  @FieldDesc(name = "账号id")
  private String accountId;

  @FieldDesc(name = "认证类型")
  @Convert(converter = ThirdPartyAuthTypeConverter.class)
  @TypeConverter(toTypeFullName = "java.lang.Integer")
  private ThirdPartyAuthType thirdPartyAuthType;

  @FieldDesc(name = "三方openId")
  private String thirdOpenId;

  @FieldDesc(name = "扩展字段")
  private String ext;



  @Convert(converter = ValidStatusConverter.class)
  @IgnoreUpdater
  @IgnoreCreator
  private ValidStatus validStatus;

  public void init() {
    setValidStatus(ValidStatus.VALID);
  }

  public void valid(){
    setValidStatus(ValidStatus.VALID);
  }

  public void invalid(){
    setValidStatus(ValidStatus.INVALID);
  }
}
